package com.itheima.app.controller;

import com.alibaba.fastjson.JSON;
import com.itheima.app.manager.SoulManager;
import com.itheima.pojo.Answer;
import org.bson.types.ObjectId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
public class SoulController {
    @Autowired
    private SoulManager soulManager;
    @GetMapping("/testSoul")
    //展示全部问卷的接口
    public ResponseEntity testSoul(@RequestHeader("Authorization")String token)
    {
        return soulManager.testSoul();
    }
    @PostMapping("/testSoul")
    //提交问卷答案的接口
    public ResponseEntity commitQuestionnaire(@RequestHeader("Authorization")String token, @RequestBody Map<String,List<Answer>> params)
    {
        List<Answer> answers = params.get("answers");
        return soulManager.commitQuestionnaire(answers);
    }
    @GetMapping("/testSoul/report/{reportId}")
    public ResponseEntity reportById(@PathVariable Long reportId)
    {
        return soulManager.reportById(reportId);
    }
}
